package com.example.hellodocker.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.sun.javafx.collections.MappingChange;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * {@code @Author} ChenZY
 * {@code @Date}  2023/10/7 15:28
 * {@code @Description}
 */

@RestController
@RequestMapping("/api")
@Api(tags = "01.用户管理模块")
public class ApiSwagger2Controller {


    @Resource
    private ObjectMapper mapper;

    @PostMapping("/ps")
    @ApiOperation(value = "接受json参数", notes = "演示json参数是否接受成功")
    public String post(@ApiParam(name = "接收json参数", defaultValue = "{}")
                       @RequestBody String json) throws IOException {
        MappingChange.Map map = mapper.readValue(json, MappingChange.Map.class);
        System.out.println(map);
        return json;
    }


}
